package love.yuanmengrobot.qdkaoqin.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import java.util.List;

import love.yuanmengrobot.qdkaoqin.R;

import love.yuanmengrobot.qdkaoqin.entity.StudentAttendanceDate;

public class StudentKaoqinAdapter  extends ArrayAdapter<StudentAttendanceDate> {


    private List<StudentAttendanceDate> mAttendanceData;
    private Context mContext;
    private int resourceId;
    public StudentKaoqinAdapter(Context context,
                         int resourceId, List<StudentAttendanceDate> data) {
        super(context, resourceId, data);
        this.mContext = context;
        this.mAttendanceData = data;
        this.resourceId = resourceId;
    }
    @Override
    public View getView(int position,
                        View convertView, ViewGroup parent) {
        StudentAttendanceDate studentAttendanceDate = getItem(position);
        View view ;
        final StudentKaoqinAdapter.ViewHolder vh;
        if (convertView == null) {
            view = LayoutInflater.from(getContext())
                    .inflate(resourceId, parent, false);
            vh = new StudentKaoqinAdapter.ViewHolder();
            vh.tvKaoqinname  = view.findViewById(R.id.kaoqin_name);
            vh.tvKaoqinstate = view.findViewById(R.id.kaoqin_status);
            vh.tvKaoqintime = view.findViewById(R.id.kaoqin_time);

            view.setTag(vh);/////**
        } else {
            view = convertView;
            vh = (StudentKaoqinAdapter.ViewHolder) view.getTag();
        }
        vh.tvKaoqinname.setText(studentAttendanceDate.getAtname());
        vh.tvKaoqinstate.setText(studentAttendanceDate.getAtsstate());
        vh.tvKaoqintime.setText(studentAttendanceDate.getAtstime());

        return view;
    }
    class ViewHolder {
        TextView tvKaoqinname;
        TextView tvKaoqinstate;
        TextView tvKaoqintime;
    }



}
